package com.feiwo.nonego.rpc.serialization.api;

import com.feiwo.nonego.rpc.common.constants.CommonConstants;
import com.feiwo.nonego.rpc.spi.annotation.SPI;

/**
 * @author feiwo 2025-08-05
 */
@SPI(CommonConstants.SERIALIZATION_JDK)
public interface Serialization {

    /**
     * 序列化
     *
     * @param obj T
     * @return byte[]
     */
    <T> byte[] serialize(T obj);

    /**
     * 反序列化
     *
     * @param data byte[]
     * @param clazz  Class
     * @return  T
     */
    <T> T deserialize(byte[] data, Class<T> clazz);
}
